<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'HomeController@index');
});


Route::group(['middleware' => ['web'], 'namespace' => 'Admin', 'prefix' => 'admin'], function () {
    Route::auth();

    //菜单权限部分
    Route::get('/home',                         ['as' => 'admin.home',                      'uses' => 'HomeController@index']);
    Route::resource('admin_user',               'AdminUserController');
    Route::resource('role',                     'RoleController');
    Route::resource('permission',               'PermissionController');
    Route::resource('blog',                     'BlogController');    
    Route::post('admin_user/destroyall',        ['as'=>'admin.admin_user.destroy.all',      'uses'=>'AdminUserController@destroyAll']);
    Route::get('admin_user/password/{id}',      ['as'=>'admin.admin_user.password',         'uses'=>'AdminUserController@password']);
    Route::post('admin_user/password_post/{id}',['as'=>'admin.admin_user.password_post',    'uses'=>'AdminUserController@password_post']);
    Route::post('role/destroyall',              ['as'=>'admin.role.destroy.all',            'uses'=>'RoleController@destroyAll']);
    Route::get('role/{id}/permissions',         ['as'=>'admin.role.permissions',            'uses'=>'RoleController@permissions']);
    Route::post('role/{id}/permissions',        ['as'=>'admin.role.permissions',            'uses'=>'RoleController@storePermissions']);
    Route::post('permission/destroyall',        ['as'=>'admin.permission.destroy.all',      'uses'=>'PermissionController@destroyAll']);
    // END
    Route::get('test',                          ['as'=>'admin.test.list',                   'uses'=>'TestController@index']);
});


Route::get('/admin', function () {
    return view('admin.welcome');
});

Route::group(['middleware' => 'web'], function () {
    Route::auth();

    Route::get('/home', 'HomeController@index');
});
